﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sbook.AdminIstrator
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            { }
        }

        protected void Login_Click(object sender, EventArgs e)
        {
            if (Business.UserService.isLogin(txtUsername.Text, txtPassword.Text))
            {
                if (Business.UserService.isAdmin(txtUsername.Text, txtPassword.Text))
                {
                    Data.Mysession.Session = Business.UserService.User_GetByUserPass(txtUsername.Text, txtPassword.Text)[0];
                    Response.Redirect("/AdminIstrator/Default.aspx");
                }
                else
                {
                    Data.Mysession.Session = Business.UserService.User_GetByUserPass(txtUsername.Text, txtPassword.Text)[0];
                    Response.Redirect("/index.aspx");
                }
            }
            else
                Response.Write("sai ten dang nhap hoac pass!");
        }
      
    }
}